<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="数量" id="i1">
<input type="button" value="添加帅哥" onclick="f(1)">
<input type="button" value="添加美女" onclick="f(2)">

<script>

    function f(x){
        for (let j = 0; j < i1.value; j++) {
            let i = document.createElement("img");
            i.src= x==1?"a.jpg":"b.jpg";
            document.body.appendChild(i);
        }

    }

</script>
</body>
</html>